package com.bear.sgg.springboot_03_yaml.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @ClassNmae Pet
 * @Description TODO
 * @Author bear
 * @Date 2020/3/4 0004 下午 7:09
 */
/*
* 使用@Value注解为类的实例赋值
* 这种方式支持：1.从配置文件中取值。2.spEL表达式语言
* */
@Component
public class PetWithValue {

    @Value("${person.mPet.name}")
    private String name;

    @Value("#{10*5}")
    private int age;

    @Override
    public String toString() {
        return "PetWithValue{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
